package org.example;

import java.math.BigDecimal;

public abstract class Fruit {

    private final String name;
    private final BigDecimal price;
    private BigDecimal discount;

    private final static BigDecimal DEFAULT_DISCOUNT = new BigDecimal("1");

    public Fruit(String name, BigDecimal price) {
        this.name = name;
        this.price = price;
        this.discount = DEFAULT_DISCOUNT;
    }

    public Fruit(String name, BigDecimal price, BigDecimal discount) {
        this.name = name;
        this.price = price;
        this.discount = discount;
    }

    public BigDecimal calculatePrice(int quantity) {
        return price.multiply(BigDecimal.valueOf(quantity));
    }

    public BigDecimal calculatePrice(int quantity, BigDecimal discount) {
        return price.multiply(BigDecimal.valueOf(quantity)).multiply( discount);
    }

    public String getName() {
        return name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

}